<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="keywords" content="集群,部署" />
	<meta name="description" content="集群部署说明" />
	<!-- 网页标签标题 -->
	<title>集群部署说明</title>
	<link rel="shortcut icon" href="https://img.alicdn.com/tfs/TB1hgJpHAPoK1RjSZKbXXX1IXXa-64-64.png"/>
	<link rel="stylesheet" href="/build/documentation.css" />
</head>
<body>
	<div id="root"><div class="documentation-page" data-reactroot="" data-reactid="1" data-react-checksum="-2125066891"><header class="header-container header-container-normal" data-reactid="2"><div class="header-body" data-reactid="3"><a href="/zh-cn/index.html" data-reactid="4"><img class="logo" src="/img/nacos_colorful.png" data-reactid="5"/></a><div class="search search-normal" data-reactid="6"><span class="icon-search" data-reactid="7"></span></div><span class="language-switch language-switch-normal" data-reactid="8">En</span><div class="header-menu" data-reactid="9"><img class="header-menu-toggle" src="/img/menu_gray.png" data-reactid="10"/><ul data-reactid="11"><li class="menu-item menu-item-normal" data-reactid="12"><a href="/zh-cn/index.html" data-reactid="13">首页</a></li><li class="menu-item menu-item-normal menu-item-normal-active" data-reactid="14"><a href="/zh-cn/docs/what-is-nacos.html" data-reactid="15">文档</a></li><li class="menu-item menu-item-normal" data-reactid="16"><a href="/zh-cn/blog/index.html" data-reactid="17">博客</a></li><li class="menu-item menu-item-normal" data-reactid="18"><a href="/zh-cn/community/index.html" data-reactid="19">社区</a></li><li class="menu-item menu-item-normal" data-reactid="20"><a href="https://cn.aliyun.com/product/aliware/mse?spm=nacos-website.topbar.0.0.0" data-reactid="21">企业版Nacos</a><img class="menu-img" src="https://img.alicdn.com/tfs/TB1esl_m.T1gK0jSZFrXXcNCXXa-200-200.png" data-reactid="22"/></li><li class="menu-item menu-item-normal" data-reactid="23"><a href="https://job.alibaba.com/zhaopin/position_detail.htm?trace=qrcode_share&amp;positionCode=GP633620" data-reactid="24">招贤纳士</a><img class="menu-img" src="https://img.alicdn.com/tfs/TB1esl_m.T1gK0jSZFrXXcNCXXa-200-200.png" data-reactid="25"/></li><li class="menu-item menu-item-normal" data-reactid="26"><a href="http://console.nacos.io/nacos/index.html" data-reactid="27">控制台样例</a></li></ul></div></div></header><div class="bar" data-reactid="28"><div class="bar-body" data-reactid="29"><img src="/img/docs.png" class="front-img" data-reactid="30"/><div class="bar-title" data-reactid="31"><span data-reactid="32">Nacos 文档</span><div class="bone bone-light" data-reactid="33"></div></div><img src="/img/docs.png" class="back-img" data-reactid="34"/></div></div><section class="content-section" data-reactid="35"><div class="content-body" data-reactid="36"><div class="sidemenu" data-reactid="37"><div class="sidemenu-toggle" data-reactid="38"><img src="https://img.alicdn.com/tfs/TB1E6apXHGYBuNjy0FoXXciBFXa-200-200.png" data-reactid="39"/></div><ul data-reactid="40"><li class="menu-item menu-item-level-1" data-reactid="41"><span data-reactid="42">Nacos </span><ul data-reactid="43"><li style="height:180px;overflow:hidden;" class="menu-item menu-item-level-2" data-reactid="44"><span data-reactid="45"><!-- react-text: 46 -->Nacos是什么?<!-- /react-text --><img style="transform:rotate(0deg);" class="menu-toggle" src="/img/arrow_down.png" data-reactid="47"/></span><ul data-reactid="48"><li class="menu-item menu-item-level-3" data-reactid="49"><a href="/zh-cn/docs/what-is-nacos.html" target="_self" data-reactid="50">Nacos简介</a></li><li class="menu-item menu-item-level-3" data-reactid="51"><a href="/zh-cn/docs/concepts.html" target="_self" data-reactid="52">概念</a></li><li class="menu-item menu-item-level-3" data-reactid="53"><a href="/zh-cn/docs/architecture.html" target="_self" data-reactid="54">架构</a></li><li class="menu-item menu-item-level-3" data-reactid="55"><a href="/zh-cn/docs/feature-list.html" target="_self" data-reactid="56">功能和需求列表</a></li></ul></li><li style="height:324px;overflow:hidden;" class="menu-item menu-item-level-2" data-reactid="57"><span data-reactid="58"><!-- react-text: 59 -->快速开始<!-- /react-text --><img style="transform:rotate(0deg);" class="menu-toggle" src="/img/arrow_down.png" data-reactid="60"/></span><ul data-reactid="61"><li class="menu-item menu-item-level-3" data-reactid="62"><a href="/zh-cn/docs/quick-start.html" target="_self" data-reactid="63">Nacos</a></li><li class="menu-item menu-item-level-3" data-reactid="64"><a href="/zh-cn/docs/quick-start-spring.html" target="_self" data-reactid="65">Nacos Spring</a></li><li class="menu-item menu-item-level-3" data-reactid="66"><a href="/zh-cn/docs/quick-start-spring-boot.html" target="_self" data-reactid="67">Nacos Spring Boot</a></li><li class="menu-item menu-item-level-3" data-reactid="68"><a href="/zh-cn/docs/quick-start-spring-cloud.html" target="_self" data-reactid="69">Nacos Spring Cloud</a></li><li class="menu-item menu-item-level-3" data-reactid="70"><a href="/zh-cn/docs/quick-start-docker.html" target="_self" data-reactid="71">Nacos Docker</a></li><li class="menu-item menu-item-level-3" data-reactid="72"><a href="/zh-cn/docs/use-nacos-with-dubbo.html" target="_self" data-reactid="73">Nacos Dubbo</a></li><li class="menu-item menu-item-level-3" data-reactid="74"><a href="/zh-cn/docs/use-nacos-with-kubernetes.html" target="_self" data-reactid="75">Nacos k8s</a></li><li class="menu-item menu-item-level-3" data-reactid="76"><a href="/zh-cn/docs/nacos-sync.html" target="_self" data-reactid="77">Nacos Sync</a></li></ul></li><li style="height:252px;overflow:hidden;" class="menu-item menu-item-level-2" data-reactid="78"><span data-reactid="79"><!-- react-text: 80 -->用户指南<!-- /react-text --><img style="transform:rotate(0deg);" class="menu-toggle" src="/img/arrow_down.png" data-reactid="81"/></span><ul data-reactid="82"><li class="menu-item menu-item-level-3" data-reactid="83"><a href="/zh-cn/docs/sdk.html" target="_self" data-reactid="84">Java的SDK</a></li><li class="menu-item menu-item-level-3" data-reactid="85"><a href="/zh-cn/docs/other-language.html" target="_self" data-reactid="86">其他语言的SDK</a></li><li class="menu-item menu-item-level-3" data-reactid="87"><a href="/zh-cn/docs/open-api.html" target="_self" data-reactid="88">Open-API指南</a></li><li class="menu-item menu-item-level-3" data-reactid="89"><a href="/zh-cn/docs/nacos-spring.html" target="_self" data-reactid="90">Nacos Spring</a></li><li class="menu-item menu-item-level-3" data-reactid="91"><a href="/zh-cn/docs/system-configurations.html" target="_self" data-reactid="92">Nacos系统参数介绍</a></li><li class="menu-item menu-item-level-3" data-reactid="93"><a href="/zh-cn/docs/faq.html" target="_self" data-reactid="94">FAQ</a></li></ul></li><li style="height:36px;overflow:hidden;" class="menu-item menu-item-level-2" data-reactid="95"><span data-reactid="96"><!-- react-text: 97 -->运维指南<!-- /react-text --><img style="transform:rotate(-90deg);" class="menu-toggle" src="/img/arrow_down.png" data-reactid="98"/></span><ul data-reactid="99"><li class="menu-item menu-item-level-3" data-reactid="100"><a href="/zh-cn/docs/deployment.html" target="_self" data-reactid="101">部署手册</a></li><li class="menu-item menu-item-level-3" data-reactid="102"><a href="/zh-cn/docs/cluster-mode-quick-start.html" target="_self" data-reactid="103">集群部署说明</a></li><li class="menu-item menu-item-level-3" data-reactid="104"><a href="/zh-cn/docs/management-api.html" target="_self" data-reactid="105">运维API</a></li><li class="menu-item menu-item-level-3" data-reactid="106"><a href="/zh-cn/docs/console-guide.html" target="_self" data-reactid="107">控制台手册</a></li><li class="menu-item menu-item-level-3" data-reactid="108"><a href="/zh-cn/docs/monitor-guide.html" target="_self" data-reactid="109">监控手册</a></li><li class="menu-item menu-item-level-3" data-reactid="110"><a href="/zh-cn/docs/nacos-config-benchmark.html" target="_self" data-reactid="111">服务配置模块压测报告</a></li><li class="menu-item menu-item-level-3" data-reactid="112"><a href="/zh-cn/docs/nacos-naming-benchmark.html" target="_self" data-reactid="113">服务发现模块压测报告</a></li><li class="menu-item menu-item-level-3" data-reactid="114"><a href="/zh-cn/docs/nacos-sync-use.html" target="_self" data-reactid="115">其他环境迁移到Nacos</a></li></ul></li><li style="height:36px;overflow:hidden;" class="menu-item menu-item-level-2" data-reactid="116"><span data-reactid="117"><!-- react-text: 118 -->开源共建<!-- /react-text --><img style="transform:rotate(-90deg);" class="menu-toggle" src="/img/arrow_down.png" data-reactid="119"/></span><ul data-reactid="120"><li class="menu-item menu-item-level-3" data-reactid="121"><a href="/zh-cn/docs/contributing.html" target="_self" data-reactid="122">贡献源码</a></li><li class="menu-item menu-item-level-3" data-reactid="123"><a href="/zh-cn/docs/contributing-flow.html" target="_self" data-reactid="124">贡献流程</a></li><li class="menu-item menu-item-level-3" data-reactid="125"><a href="/zh-cn/docs/pull-request.html" target="_self" data-reactid="126">pull request模板</a></li><li class="menu-item menu-item-level-3" data-reactid="127"><a href="/zh-cn/docs/how-to-reporting-bugs.html" target="_self" data-reactid="128">如何提交问题报告</a></li></ul></li><li style="height:36px;overflow:hidden;" class="menu-item menu-item-level-2" data-reactid="129"><span data-reactid="130"><!-- react-text: 131 -->社区<!-- /react-text --><img style="transform:rotate(-90deg);" class="menu-toggle" src="/img/arrow_down.png" data-reactid="132"/></span><ul data-reactid="133"><li class="menu-item menu-item-level-3" data-reactid="134"><a href="/zh-cn/docs/community.html" target="_self" data-reactid="135">社区</a></li><li class="menu-item menu-item-level-3" data-reactid="136"><a href="/zh-cn/docs/nacos-dev.html" target="_self" data-reactid="137">开发团队</a></li></ul></li></ul></li></ul></div><div class="doc-content markdown-body" data-reactid="138"><h1>集群部署说明</h1>
<h2>集群模式部署</h2>
<p>这个快速开始手册是帮忙您快速在你的电脑上，下载安装并使用Nacos，部署生产使用的集群模式。</p>
<h3>集群部署架构图</h3>
<p>因此开源的时候推荐用户把所有服务列表放到一个vip下面，然后挂到一个域名下面</p>
<p><a href="http://ip1">http://ip1</a>:port/openAPI  直连ip模式，机器挂则需要修改ip才可以使用。</p>
<p><a href="http://VIP">http://VIP</a>:port/openAPI  挂载VIP模式，直连vip即可，下面挂server真实ip，可读性不好。</p>
<p><a href="http://nacos.com">http://nacos.com</a>:port/openAPI  域名 + VIP模式，可读性好，而且换ip方便，推荐模式</p>
<p><img src="https://cdn.nlark.com/yuque/0/2019/jpeg/338441/1561258986171-4ddec33c-a632-4ec3-bfff-7ef4ffc33fb9.jpeg" alt="deployDnsVipMode.jpg"></p>
<h2>1. 预备环境准备</h2>
<p>请确保是在环境中安装使用:</p>
<ol>
<li>64 bit OS  Linux/Unix/Mac，推荐使用Linux系统。</li>
<li>64 bit JDK 1.8+；<a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">下载</a>.<a href="https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/">配置</a>。</li>
<li>Maven 3.2.x+；<a href="https://maven.apache.org/download.cgi">下载</a>.<a href="https://maven.apache.org/settings.html">配置</a>。</li>
<li>3个或3个以上Nacos节点才能构成集群。</li>
</ol>
<h2>2. 下载源码或者安装包</h2>
<p>你可以通过两种方式来获取 Nacos。</p>
<h3>从 Github 上下载源码方式</h3>
<pre><code class="language-bash">unzip nacos-source.zip
<span class="hljs-built_in">cd</span> nacos/
mvn -Prelease-nacos clean install -U  
<span class="hljs-built_in">cd</span> nacos/distribution/target/nacos-server-1.3.0/nacos/bin
</code></pre>
<h3>下载编译后压缩包方式</h3>
<p>下载地址</p>
<p><a href="https://github.com/alibaba/nacos/releases/download/1.3.0/nacos-server-1.3.0.zip">zip包</a></p>
<p><a href="https://github.com/alibaba/nacos/releases/download/1.3.0/nacos-server-1.3.0.tar.gz">tar.gz包</a></p>
<pre><code class="language-bash">  unzip nacos-server-1.3.0.zip 或者 tar -xvf nacos-server-1.3.0.tar.gz
  <span class="hljs-built_in">cd</span> nacos/bin
</code></pre>
<h2>3. 配置集群配置文件</h2>
<p>在nacos的解压目录nacos/的conf目录下，有配置文件cluster.conf，请每行配置成ip:port。（请配置3个或3个以上节点）</p>
<pre><code class="language-plain"># ip:port
200.8.9.16:8848
200.8.9.17:8848
200.8.9.18:8848
</code></pre>
<h2>4. 确定数据源</h2>
<h3>使用内置数据源</h3>
<p>无需进行任何配置</p>
<h3>使用外置数据源</h3>
<p><span data-type="color" style="color:rgb(25, 31, 37)"><span data-type="background" style="background-color:rgb(255, 255, 255)">生产使用建议至少主备模式，或者采用高可用数据库。</span></span></p>
<h4>初始化 MySQL 数据库</h4>
<p><a href="https://github.com/alibaba/nacos/blob/master/distribution/conf/nacos-mysql.sql">sql语句源文件</a></p>
<h4>application.properties 配置</h4>
<p><a href="https://github.com/alibaba/nacos/blob/master/distribution/conf/application.properties">application.properties配置文件</a></p>
<h2>5. 启动服务器</h2>
<h3>Linux/Unix/Mac</h3>
<h4>Stand-alone mode</h4>
<pre><code class="language-bash">sh startup.sh -m standalone
</code></pre>
<h4>集群模式</h4>
<blockquote>
<p>使用内置数据源</p>
</blockquote>
<pre><code class="language-bash">sh startup.sh -p embedded
</code></pre>
<blockquote>
<p>使用外置数据源</p>
</blockquote>
<pre><code class="language-bash">sh startup.sh
</code></pre>
<h2>6. 服务注册&amp;发现和配置管理</h2>
<h3>服务注册</h3>
<p><code>curl -X PUT 'http://127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.naming.serviceName&amp;ip=20.18.7.10&amp;port=8080'</code></p>
<h3>服务发现</h3>
<p><code>curl -X GET 'http://127.0.0.1:8848/nacos/v1/ns/instances?serviceName=nacos.naming.serviceName'</code></p>
<h3>发布配置</h3>
<p><code>curl -X POST &quot;http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&amp;group=test&amp;content=helloWorld&quot;</code></p>
<h3>获取配置</h3>
<p><code>curl -X GET &quot;http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&amp;group=test&quot;</code></p>
<h2>7. 关闭服务器</h2>
<h3>Linux/Unix/Mac</h3>
<pre><code class="language-bash">sh shutdown.sh
</code></pre>
</div></div></section><footer class="footer-container" data-reactid="139"><div class="footer-body" data-reactid="140"><img src="/img/nacos_gray.png" data-reactid="141"/><div class="cols-container" data-reactid="142"><div class="col col-12" data-reactid="143"><h3 data-reactid="144">愿景</h3><p data-reactid="145">Nacos 通过提供简单易用的动态服务发现、服务配置、服务共享与管理等服务基础设施，帮助用户在云原生时代，在私有云、混合云或者公有云等所有云环境中，更好的构建、交付、管理自己的微服务平台，更快的复用和组合业务服务，更快的交付商业创新的价值，从而为用户赢得市场。</p></div><div class="col col-6" data-reactid="146"><dl data-reactid="147"><dt data-reactid="148">文档</dt><dd data-reactid="149"><a href="/zh-cn/docs/what-is-nacos.html" target="_self" data-reactid="150">概览</a></dd><dd data-reactid="151"><a href="/zh-cn/docs/quick-start.html" target="_self" data-reactid="152">快速开始</a></dd><dd data-reactid="153"><a href="/zh-cn/docs/contributing.html" target="_self" data-reactid="154">开发者指南</a></dd></dl></div><div class="col col-6" data-reactid="155"><dl data-reactid="156"><dt data-reactid="157">资源</dt><dd data-reactid="158"><a href="/zh-cn/community/index.html" target="_self" data-reactid="159">社区</a></dd><dd data-reactid="160"><a href="https://www.aliyun.com/product/acm?source_type=nacos_pc_20181219" target="_self" data-reactid="161">云服务 ACM</a></dd><dd data-reactid="162"><a href="https://www.aliyun.com/product/edas?source_type=nacos_pc_20181219" target="_self" data-reactid="163">云服务 EDAS</a></dd><dd data-reactid="164"><a href="https://www.aliyun.com/product/ahas?source_type=nacos_pc_20190225" target="_self" data-reactid="165">云服务 AHAS</a></dd></dl></div></div><div class="copyright" data-reactid="166"><span data-reactid="167">@ 2018 The Nacos Authors | An Alibaba Middleware (Aliware) Project</span></div></div></footer></div></div>
	<script src="https://f.alicdn.com/react/15.4.1/react-with-addons.min.js"></script>
	<script src="https://f.alicdn.com/react/15.4.1/react-dom.min.js"></script>
	<script>
		window.rootPath = '';
  </script>
	<script src="/build/documentation.js"></script>
</body>
</html>